<template>
	<view class="">
		<common-title :title="titleContent" @clickLeft="backToUpPage" @clickRight="editCoupleFirstMeetDay"></common-title>
		<view class="firstMeetDay">
			<view class="firstMeetDay-show">第一次见面</view>
			<picker mode="date" :value="firstMeetDay" @change="firstMeetDayChange">
				<view class="firstMeetDay-date">{{firstMeetDay}}</view>
			</picker>
		</view>
	</view>
</template>

<script setup>
	import { ref } from "vue";
	import { onLoad } from '@dcloudio/uni-app';
	import { editCoupleInfo } from "../../../../utils/apiMine";
	//================================common-title=========================================
	//标题内容
	const titleContent = ref({
		left:'',
		midst:'修改第一次见面',
		right:'保存'
	});
	
	//返回
	const backToUpPage = () => {
		uni.navigateBack();
	};
	//保存修改
	const editCoupleFirstMeetDay = async () => {
		await editCoupleInfo({'firstMeetDay': firstMeetDay.value}).then((value) => {
			// console.log(value==='200');
			if (value === '200') {
				uni.showToast({
					title:'保存成功'
				})
			}
		}).finally(() => {
			uni.redirectTo({
				url:'/pages/mine/other_set/couple-set'
			});
		})
	}
	//---------------------------------修改第一次见面日子---------------------------------------------
	const firstMeetDay = ref(null);
	onLoad((options) => {
		// 从 options 中获取 userSex
		firstMeetDay.value = options.firstMeetDay ? decodeURIComponent(options.firstMeetDay) : '';
		// console.log(userBirthday.value);
	});
	const firstMeetDayChange = (e) => {
		// console.log(e);
		firstMeetDay.value = e.detail.value;
	}
</script>

<style lang="scss" scoped>
	.firstMeetDay{
		display: flex;
		font-size: 36rpx;
		margin: 30rpx;
		.firstMeetDay-date{
			width: 550rpx;                    /* 固定宽度 */
			margin-left: 30rpx;               /* 左侧外边距 */
			border-bottom: 1px solid #676767;  /* 下边框 */
			display: flex;                    /* 子元素使用 Flexbox */
			justify-content: center;          /* 水平居中对齐 */
			flex: 1;                          /* 使生日日期在可用空间中扩展 */
			text-align: center;               /* 文字居中 */
		}
	}
</style>